/**
 * Created by Allen on 2018/3/8.
 */
import config from 'config'
import httpFetch from 'share/httpFetch'
import errorMessage from "share/errorMessage";

export default {
  //获取已启用的供应商信息详情
  getVendorDetail(vendorName){
    return httpFetch.get(`${config.baseUrl}/vendor-info-service/api/solr/vendors/function/${vendorName}`)
  },

  //获取用户列表
  getUserList(params,page,pageSize,supplierName){
    return httpFetch.get(`${config.baseUrl}/vendor-info-service/api/solr?department=${params.department}&endDate=${params.endDate}&info=${params.info}&level=${params.level}&page=${page}&size=${pageSize}&startDate=${params.startDate}&status=${params.status}&vendorName=${supplierName}`)
  },

  //获取部门
  getDepartment(){
    return httpFetch.get(`${config.baseUrl}/departments/root?flag=1002&isCompany=false`)
  },

  //关闭服务
  closeService(params){
    return new Promise(((resolve, reject) => {
      httpFetch.post(`${config.baseUrl}/api/register/close/service/by/keyorcode`, params)
        .then(res => {
          resolve(res);
        }).catch(err => {
        errorMessage(err.response);
        reject(err)
      })
    }));
  },

  //查看账号
  checkAccount(vendorName){
    return httpFetch.get(`${config.baseUrl}/vendor-info-service/api/vendors/company/config/${vendorName}/search`)
  },

  //开户
  openAccount(params){
    return httpFetch.post(`${config.baseUrl}/vendor-info-service/api/solr`,params)
  },

  //改变供应商开通权限
  setFunctionProfile(params){
    return httpFetch.post(`${config.baseUrl}/api/function/profiles`,params)
  },

  //修改携程审批方式  authorizeType (1:提前审批,2:邮件审批);
  modifyCtripService(params){
    return httpFetch.post(`${config.baseUrl}/api/ctrip/company/authorize/change?authorizeType=${params.authorizeType}&companyOID=${params.companyOID}`)
  },

  // 携程服务开启和关闭
  enableCtripServer(params){
    return httpFetch.post(`${config.baseUrl}/vendor-info-service/api/vendor/function`,params);
  },
  //查询历史数据
  queryHistoryData(type) {
    return httpFetch.get(`${config.baseUrl}/api/tenant/bankcard/accounts/${type}`);
  },
  addQueryHistoryData(type, params) {
    return httpFetch.post(`${config.baseUrl}/api/v2/bankcard/transaction/pull?bankCode=${type}`, params);
  },

  // 源慧列表数据查询
  ygetSearchList(params){
    let URL = params.operator ? `/api/yget/getTempLimit?action=${params.operator}&page=${params.pageNum - 1}`
      : `/api/yget/getTempLimit?page=${params.pageNum - 1}`;
    return httpFetch.get(`${config.baseUrl}${URL}&size=10`);
  },

  // 源慧额度调整创建获取事物ID
  ygetGetID(){
    return httpFetch.get(`${config.baseUrl}/api/yget/createTempLimit`);
  },

  // 源慧额度调整提交
  ygetAdjustCommit(params){
    return httpFetch.post(`${config.baseUrl}/api/yget/syncTempLimit`,params);
  },

  // 源慧操作对象列表
  ygetGetOperatorList(){
    return httpFetch.post(`${config.baseUrl}/api/yget/getAllAction`);
  },

  // 甄选酒店详情
  getHeliosHotel(){
    return httpFetch.get(`${config.baseUrl}/vendor-info-service/api/vendors/company/config/zhenxuan/search`);
  },

  //更新商务卡消费记录属性
  updateConsumeType(params) {
    return httpFetch.post(`${config.baseUrl}/api/function/profiles/setProfile`, params)
  },

}
